﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Globalization;
using Telerik.Web.UI;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.MODEL;
using KPIS.GERP.GHRMS.APP.Classes;
using _WebShared.Classes;

namespace KPIS.GERP.GHRMS.APP.App_UI.UserControls
{
    public partial class PS_EmployeeEducationEdit : System.Web.UI.UserControl
    {
        private SsMng ssMng = new SsMng();
        private IHisEducationBLL eduBLL = new HisEducationBLL();
        Main main = new Main();

        protected void Page_Load(object sender, EventArgs e)
        {
            LoadGrid();
        }

        public void LoadGrid()
        {
            if (ssMng.EmpSeq == null)// !Session["EmpSeq"] == null)
                return;

            string strEmpSeq = ssMng.EmpSeq;

            if (strEmpSeq.Length == 0)
                return;

            //EmployeeEducationEditGrid.DataSource = edu.LoadGridEmployeeEducations(strEmpSeq);
            //EmployeeEducationEditGrid.DataBind();
        }

        protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
        {
            //if (e.CommandName != RadGrid.ExpandCollapseCommandName)
            //{
            //    EmployeeEducationEditGrid.DataBind();
            //}
            //else 
            if (e.CommandName == "DeleteAll")
            {
                GridDataItem item;
                for (int i = 0; i < EmployeeEducationEditGrid.Items.Count; i++)
                {
                    item = EmployeeEducationEditGrid.Items[i];
                    if (item.Selected)
                    {
                        //string strPK = item.OwnerTableView.DataKeyValues[i]["edu_seq"].ToString();
                        //edu.Delete(strPK, Session["UserID"].ToString(), DateTime.Now);
                    }
                }

                LoadGrid();
                EmployeeEducationEditGrid.DataBind();// ต้อง Bind ใหม่
            }
            else if (e.CommandName == "Delete")
            {
                //string strPK = (e.Item as GridDataItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex]["edu_seq"].ToString();
                //edu.Delete(strPK, Session["UserID"].ToString(), DateTime.Now);

                //LoadGrid();
                //EmployeeEducationEditGrid.DataBind();
            }
            else if (e.CommandName == "PerformInsert" || e.CommandName == "Update")
            {
                LoadGrid();
                EmployeeEducationEditGrid.DataBind();
            }
        }
    }
}